<template lang="">
    <div>
        <van-form>
            <div v-for='(j,pindex) in list'>
                    <van-field  :label="i.label" v-model='value[pindex+i.key+pindex]'  v-for='(i,index) in j'/>
            </div>

            <van-button @click='add'>+</van-button>

            <van-button @click='save'>提交</van-button>
        </van-form>

    </div>
</template>
<script>
export default {
  data(){
    return{
      form:{},
      list:[[{'label':'名称','key':'name'},{'label':'类型','key':'type'},{'label':'值','key':'value'}]],
      value:{},
      number:1
    }
  },
  methods: {
    add(){
      this.list.push([{'label':'名称','key':'name'},{'label':'类型','key':'type'},{'label':'值','key':'value'}])
      this.number +=1
    },
    save(){
      var l=[]
      for(var i=0;i<this.number;i++){
        var name = i+'name'+i
        var type =  i+'type'+i
        var v =  i+'value'+i
        var dict = {'name':this.value[name],'value':this.value[v],'type':this.value[type]}
        l.push(dict)
      }
      console.log(l)

    },
  },
}
</script>
<style lang="">

</style>
